﻿#-------------------------------------------------------------------------------
# Name:        familyid
# Purpose:
#
# Author:      SUPER_紫电  QQ,911344755
#
# Created:     29/01/2023
# Copyright:  (c) SUPER_紫电 2022 All rights reserved.
# Licence:    <Modified BSD License>
#-------------------------------------------------------------------------------

cfg_file_ext = 'family_id'
cfg_code_ext = ''
try:
    import ast
    with open('..\\{}.cfg'.format(cfg_file_ext), encoding='utf8') as cfg_file:
        for line in cfg_file:
            line = line.replace(' ', '').replace('\n', '')
            if line[0:len(cfg_file_ext)] == cfg_file_ext:
                line = '{'
            if line[0:1] == '#' or len(line) < 1:
                continue
            cfg_code_ext += line
        cfg_code_ext = ast.literal_eval(cfg_code_ext)
except:
    cfg_code_ext = {}

family_id = {
#-------------------------------------------------------------------------------
#    Product ID 16 Bit + Globle Product ID
#-------------------------------------------------------------------------------
    #'0x0000': {'pcb': '2060-xxxxxx-xxx', 'name': 'xxxx'},
    '0x010D': {'pcb': '2060-771698-002', 'name': 'DRAGON'},
    '0x010E': {'pcb': '2060-771624-003', 'name': 'MANPL_RE'},
    '0x0110': {'pcb': '2060-771642-003', 'name': 'DF4PL_RE'},
    '0x0112': {'pcb': '2060-771696-004', 'name': 'AZTEC_PL'},
    '0x0119': {'pcb': '2061-771672-E04', 'name': 'SHASTA2D'},
    '0x011C': {'pcb': '2060-xxxxxx-xxx', 'name': 'SHASTA3D'},
    '0x011E': {'pcb': '2061-771714-002', 'name': 'EUROPA'},
    '0x011F': {'pcb': '2060-771672-004', 'name': 'JAM_4K'},
    '0x0122': {'pcb': '2060-771702-001', 'name': 'SUMT_RE'},
    '0x0123': {'pcb': '2060-xxxxxx-xxx', 'name': 'MARN5_4K'},
    '0x0125': {'pcb': '2060-771640-003', 'name': 'TAHOE_LT'},
    '0x0126': {'pcb': '2060-xxxxxx-xxx', 'name': 'SADLE_BK'},
    '0x012D': {'pcb': '2060-771692-005', 'name': 'ZEPHYR', '0x040F': {'pcb': '2060-771692-005', 'name': 'ZEPHYR'}, '0x058C': {'pcb': '2060-771820-000', 'name': 'ZEPHYR_N'},},
    '0x0133': {'pcb': '2060-771698-002', 'name': 'SADLE_G6'},
    '0x0134': {'pcb': '2060-xxxxxx-xxx', 'name': 'HELIOS'},
    '0x013E': {'pcb': '2060-771629-006', 'name': 'ESPRIT'},
    '0x013F': {'pcb': '2060-xxxxxx-xxx', 'name': 'EVERESTV'},
    '0x0144': {'pcb': '2060-xxxxxx-xxx', 'name': 'DRACO'},
    '0x0148': {'pcb': '2060-771698-004', 'name': 'SADLE_2D'},
    '0x0157': {'pcb': '2060-771823-002', 'name': 'SHREK'},
    '0x015F': {'pcb': '2060-771822-002', 'name': 'KOJN_RE'},
    '0x0161': {'pcb': '2060-771824-006', 'name': 'TRESSELS', '0x0496': {'pcb': '2060-771824-006', 'name': 'TRESSELS'},},
    '0x0162': {'pcb': '2060-771824-003', 'name': 'DIABLO3D'},
    '0x0163': {'pcb': '2060-771824-005', 'name': 'TRAILS'},
    '0x0167': {'pcb': '2060-771820-000', 'name': 'JAM_4KV'},
    '0x016F': {'pcb': '2061-771829-003', 'name': 'TRESSELB'},
    '0x0170': {'pcb': '2060-xxxxxx-xxx', 'name': 'INCA'},
    '0x0177': {'pcb': '2060-771852-004', 'name': 'HUBBLE'},
    '0x0179': {'pcb': '2060-771640-003', 'name': 'TAHOE_XL'},
    '0x0184': {'pcb': '2060-xxxxxx-xxx', 'name': 'SDB6GM'},
    '0x018E': {'pcb': '2060-771945-001', 'name': 'TRESXLS'},
    '0x01D6': {'pcb': '2060-771927-002', 'name': 'BIGBEAR'},
    '0x01F3': {'pcb': '2060-771959-000', 'name': 'HUBBLELT'},
    '0x0200': {'pcb': '2060-xxxxxx-xxx', 'name': 'GIANT'},
    '0x0203': {'pcb': '2060-771933-000', 'name': 'FBLITE'},
    '0x0206': {'pcb': '2060-771945-001', 'name': 'DIABLO3S'},
    '0x0207': {'pcb': '2060-771945-000', 'name': 'TRAILXLS'},
    '0x020B': {'pcb': '2060-xxxxxx-xxx', 'name': 'SHREKLT'},
    '0x021C': {'pcb': '2060-xxxxxx-xxx', 'name': 'MALIBU'},
    '0x0225': {'pcb': '2060-800001-002', 'name': 'REMBRNDT'},
    '0x023B': {'pcb': '2060-800039-001', 'name': 'TRESXLB2'},
    '0x023C': {'pcb': '2060-800025-001', 'name': 'HUBLT2'},
#-------------------------------------------------------------------------------
#    Product ID + Globle Product ID
#-------------------------------------------------------------------------------
    '0x1250': {'pcb': '2060-xxxxxx-xxx', 'name': 'Scorpio'},
    '0x1278': {'pcb': '2060-701450-001', 'name': 'Aries'},
    '0x127A': {'pcb': '2060-701499-000', 'name': 'Mckinley'},
    '0x129E': {'pcb': '2060-701499-003', 'name': 'Denali'},
    '0x15B6': {'pcb': '2060-xxxxxx-xxx', 'name': 'Venus'},
    '0x167D': {'pcb': '2060-701477-002', 'name': 'Tornado 2D'},
    '0x167F': {'pcb': '2060-701444-004', 'name': 'Sequoia_Zuma'},
    '0x1681': {'pcb': '2060-701477-002', 'name': 'Tornado 3D'},
    '0x1689': {'pcb': '2060-xxxxxx-xxx', 'name': 'JUP_ZUMA'},
    '0x1690': {'pcb': '2060-701444-004', 'name': 'TD2_PMR'},
    '0x1691': {'pcb': '2060-701552-003', 'name': 'Sequoia PMR'},
    '0x1692': {'pcb': '2060-701537-002', 'name': 'YOSEMITE'},
    '0x1694': {'pcb': '2060-701543-005', 'name': 'Viking'},
    '0x1695': {'pcb': '2060-771477-002', 'name': 'TD3_PMR'},
    '0x1696': {'pcb': '2060-701474-002', 'name': 'Hulk'},
    '0x169B': {'pcb': '2060-701477-002', 'name': 'Spider'},
    '0x169D': {'pcb': '2060-701590-000', 'name': 'Atlantis'},
    '0x169F': {'pcb': '2060-701537-000', 'name': 'Pinnacle'},
    '0x16A0': {'pcb': '2060-701567-000', 'name': 'Mars'},
    '0x16A3': {'pcb': '2060-701444-003', 'name': 'Sequoia_RE'},
    '0x16A5': {'pcb': '2060-701477-002', 'name': 'TD2_PMR'},
    '0x16A6': {'pcb': '2060-701474-002', 'name': 'HULK_RE'},
    '0x16AB': {'pcb': '2060-701537-004', 'name': 'Atlantis_RE'},
    '0x16AC': {'pcb': '2060-701567-000', 'name': 'Mars_RE'},
    '0x16B1': {'pcb': '2060-701590-000', 'name': 'Kermit'},
    '0x16B3': {'pcb': '2060-xxxxxx-xxx', 'name': 'Saturn'},
    '0x16B4': {'pcb': '2060-701537-004', 'name': 'Pinnacle_RE'},
    '0x16B6': {'pcb': '2060-701578-001', 'name': 'Cypress'},
    '0x16B7': {'pcb': '2061-701572-400', 'name': 'Mercury'},
    '0x16B8': {'pcb': '2060-771577-001', 'name': 'Pinnacle_HF'},
    '0x16B9': {'pcb': '2060-771577-001', 'name': 'Atlantis_HF'},
    '0x16BA': {'pcb': '2060-701590-000', 'name': 'Gekko'},
    '0x16BB': {'pcb': '2060-xxxxxx-xxx', 'name': 'SPART_RE'},
    '0x16BE': {'pcb': '2060-xxxxxx-xxx', 'name': 'Mars_HF'},
    '0x16C3': {'pcb': '2060-771624-001', 'name': 'Mantis'},
    '0x16C4': {'pcb': '2060-7016721609', 'name': 'SHASTA_P'},
    '0x16C6': {'pcb': '2060-701640-000', 'name': 'Tahoe'},
    '0x16C7': {'pcb': '2060-xxxxxx-xxx', 'name': 'Everest5'},
    '0x16C8': {'pcb': '2060-701590-000', 'name': 'Midori'},
    '0x16CB': {'pcb': '2060-771590-001', 'name': 'PINCLITE'},
    '0x16CD': {'pcb': '2060-xxxxxx-xxx', 'name': 'Pluto'},
    '0x16CE': {'pcb': '2060-771640-003', 'name': 'DF2_PL4K'},
    '0x16D3': {'pcb': '2060-771672-001', 'name': 'Mariner', '0x03DE': {'pcb': '2060-771672-004', 'name': 'MARINER5'},},
    '0x16D5': {'pcb': '2060-701590-001', 'name': 'Pinnacle PATA'},
    '0x16D9': {'pcb': '2060-701640-001', 'name': 'DragFly1'},
    '0x16DB': {'pcb': '2060-701640-002', 'name': 'DF3_PL4K'},
    '0x16DE': {'pcb': '2060-xxxxxx-xxx', 'name': 'Mozrt_RE'},
    '0x16DF': {'pcb': '2060-7016401642', 'name': 'DragFly4'},
    '0x16E2': {'pcb': '2060-771640-002', 'name': 'Tahoe 2D'},
    '0x16E3': {'pcb': '2060-771642-001', 'name': 'Mantis_RE'},
    '0x16E5': {'pcb': '2061-771672-004', 'name': 'Jamaica'},
    '0x16E6': {'pcb': '2060-771702-001', 'name': 'Vulcan_RE'},
    '0x16E8': {'pcb': '2060-771823-000', 'name': 'FireBird'},
    '0x16EB': {'pcb': '2060-xxxxxx-xxx', 'name': 'MOJITO'},
    '0x16EC': {'pcb': '2060-701640-002', 'name': 'Tahoe_PL'},
    '0x16ED': {'pcb': '2060-701574-001', 'name': 'Mercury'},
}

family_id.update(cfg_code_ext)

def get_family_name(prod_id, prod_id16, glob_prod_id):
    familyname = 'UNKNOWN'
    familyid = prod_id16 if (prod_id & 0xFF) == 0xFE else prod_id
    if '0x%04X'%familyid in family_id:
        if '0x%04X'%glob_prod_id in family_id['0x%04X'%familyid]:
            familyname = family_id['0x%04X'%familyid]['0x%04X'%glob_prod_id]['name']
        else:
            familyname = family_id['0x%04X'%familyid]['name']
    return familyid, familyname

def sort_list(code_list):
    for i in range(len(code_list)):
        print(code_list[i])
    for i in range(len(code_list)):
        line = str(code_list[i])
        line = line.replace(',', ':')
        line = line.replace('(', '')
        line = line.replace(')', ',')
        print(line)

def sort_family_id():
    family_list = sorted(family_id.items(), key=lambda x:x[0])
    sort_list(family_list)

#sort_family_id()
